package com.xuan.factory.abstarct;

/**
 * 抽象工厂模式
 * @产品：     Phone Computer PhoneEar ComputerEar
 * @抽象工厂：   AbstractFactory
 * @具体工厂：   PhoneFactory ComputerFactory
 * @description:    每一个具体的工厂可以一类产品族，比如手机工厂可以生产手机和手机配件
 */
public class AbstractFactoryDemo {
    public static void main(String[] args) {
        // 生产手机产品族
        PhoneFactory phoneFactory = new PhoneFactory();
        Device phone = phoneFactory.createDevice();
        Accessory phoneEar = phoneFactory.createAccessory();
        phone.produce();
        phoneEar.produce();

        System.out.println("-----------------");

        // 生产电脑产品族
        ComputerFactory computerFactory = new ComputerFactory();
        Device computer = computerFactory.createDevice();
        Accessory computerEar = computerFactory.createAccessory();
        computer.produce();
        computerEar.produce();

    }
}
